import axios from 'axios';
import qs from 'qs' // 序列化参数使用的
// import {getH,postH,postJSONH} from "./http"; //引入get和post操作
import {req , postJSON} from './axiosFun';

//export const MachineConfigList = (params) => { return req("post", "/api/MachineConfig/list", params) };

// export const kaptcha = (params) => {
//   return req("get","/api/back_user/kaptcha");
// };

//获取验证码
export const kaptcha = (params) => {
  return axios.get("/api/back_user/kaptcha");
};

//登录
export const login = (params) => {
  return req("post","/api/back_user/login",params);
  // return axios({
  //   url:"/api/back_user/login",
  //   method: "POST",
  //   headers:{
  //     'Content-Type': 'application/json;charset=UTF-8',
  //     token: localStorage.getItem('logintoken')
  //   },
  //   data:JSON.stringify(params)
  // });
};

//注册
export const register = (params) => {
  // return req("post", "/api/back_user/register",params);
  return axios({
    url:"/api/back_user/register",
    method: "POST",
    headers:{
      'Content-Type': 'application/json;charset=UTF-8',
      token: localStorage.getItem('logintoken')
    },
    data:JSON.stringify(params)
  });
};

//注销
export const cancellation = (params) => {
  return req("delete", "/api/back_user/del_back_user");
};

//管理停车场价格
export const managerPrice = (params) => {
  return axios({
    method: 'put',
    url: '/api/parking/s_price',
    headers:{
      // 'Content-Type': 'application/x-www-form-urlencoded',
      token: localStorage.getItem('logintoken'),
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: JSON.stringify(params)
  });
}

//录入停车场信息
export const enrollInfo = (params) => {
  // return req("post","/api/parking",params);
  return axios({
    url:"/api/parking",
    method: "POST",
    headers:{
      'Content-Type': 'application/json;charset=UTF-8',
      token: localStorage.getItem('logintoken')
    },
    data:JSON.stringify(params)
  });
};

//显示停车场信息
export const showInfo = (params) => {
  return req("get", "/api/parking",params);
};

//修改停车场信息
export const managerInfo = (params) => {
  // return req("put","/api/parking",params);
  return axios({
    url:"/api/parking",
    method: "PUT",
    // contentType: 'application/json',
    headers:{
      // 'Content-Type': 'application/x-www-form-urlencoded',
      token: localStorage.getItem('logintoken'),
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data:JSON.stringify(params)
  });
};

//删除停车场
export const delInfo = (params) => {
  // return req("delete","/api/parking",params);
  // return req("delete","/api/parking/"+params);
  // return axios("get","/api/parking/"+params);
  return axios({
    url:"/api/parking/del/"+params,
    method: "get",
    headers:{
      // 'Content-Type': 'application/x-www-form-urlencoded',
      token: localStorage.getItem('logintoken'),
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
  // return axios({
  //   url:"/api/parking",
  //   method: "delete",
  //   // contentType: 'application/json',
  //   headers:{
  //     // 'Content-Type': 'application/x-www-form-urlencoded',
  //     token: localStorage.getItem('logintoken'),
  //     'Content-Type': 'application/json;charset=UTF-8'
  //   },
  //   data:{id:params}
  // });
};
